
// ==================== src/pages/Error/ErrorPage.tsx ====================
import React from 'react';
import { Result, Button } from 'antd';
import { useNavigate, useRouteError } from 'react-router-dom';

const ErrorPage: React.FC = () => {
  const navigate = useNavigate();
  const error = useRouteError() as any;

  console.error('Route error:', error);

  return (
    <div style={{ padding: '50px', textAlign: 'center' }}>
      <Result
        status="404"
        title="404"
        subTitle={error?.statusText || error?.message || '页面不存在'}
        extra={
          <Button type="primary" onClick={() => navigate('/')}>
            返回首页
          </Button>
        }
      />
    </div>
  );
};

export default ErrorPage;